<div class="wrap-left">

      <div class="pb-list temp-tree">
        <h2> Hãng Sản Xuất</h2>
        <?php
			$hangsanxuat = new hangsanxuat();
			$lsthsx = $hangsanxuat->getAllHangSanXuatByWhere("TrangThai=1","");
		?>
        <ul class="ls">
		<?php foreach($lsthsx as $item) : ?>
          <li>
            <h3> <a href="<?php echo __URL_BASE ?>tivi/danh-muc-san-pham/<?php echo $item->id ?>/<?php echo utility::utf8tourl(trim($item->TenHang));  ?>.html" title="TV Sony"><?php echo $item->TenHang; ?></a></h3>
          </li>
          <?php endforeach; ?>
        </ul>
        <div class="cl"> </div>
      </div>
      <div class="cl"> </div>
      <div class="pa-list temp-tree">
        <h2> Tìm kiếm</h2>
        
        <form method="post" action="<?php echo __URL_BASE.'index.php?rt=tivi/urlsearchtivi' ?>" >
         <select name="hang">
        	<option value="0">------------ Chọn hãng ------------</option>
        	<?php 
				$selected_hang = isset($_REQUEST['hang']) ? $_REQUEST['hang'] : 0;
				foreach($lsthsx as $item) :	
			?>
            		<option value="<?php echo $item->id ?>" 
						<?php if($selected_hang == $item->id) echo 'selected="selected"'  ?>><?php echo $item->TenHang ?>
                    </option>
            <?php
				endforeach;
			?>
        </select>
        <select name="gia">
        	<?php $selected_gia = isset($_REQUEST['gia']) ? $_REQUEST['gia'] : 0; ?>
        	<option value="0">------------- Chọn giá -------------</option>
        	<option value="1" <?php if($selected_gia == '1') echo 'selected="selected"'  ?>>Dưới 7 Triệu</option>
            <option value="2" <?php if($selected_gia == '2') echo 'selected="selected"'  ?>>Từ 7 Triệu đến 15 Triệu</option>
            <option value="3" <?php if($selected_gia == '3') echo 'selected="selected"'  ?>>Từ 15 Triệu đến 30 Triệu</option>
            <option value="4" <?php if($selected_gia == '4') echo 'selected="selected"'  ?>>Trên 30 Triệu</option>
        </select>
        <select name="loai">
        	<option value="0">------------- Chọn loại -------------</option>
			<?php 
				$loaitivi = new loaitivi();
				$lstloaitv = $loaitivi->getAllLoaiTiviByWhere('TrangThai=1','');
				$selected_loai = isset($_REQUEST['loai']) ? $_REQUEST['loai'] : 0;
				foreach($lstloaitv as $item):
			?>
            		<option value="<?php echo $item->id ?>" <?php if($selected_loai == $item->id) echo 'selected="selected"'  ?>>
						<?php echo $item->TenLoai ?>
                    </option>
            <?php
				endforeach;
			?>
        </select>
        <select name="kichthuoc">
        	<option value="0">------- Chọn kích thước -------</option>
			<?php 
				$tivi = new tivi();
				$lstKichThuoc = $tivi->getKichThuocTivi();
				$selected_kt = isset($_REQUEST['kichthuoc']) ? $_REQUEST['kichthuoc'] : 0;
				foreach($lstKichThuoc as $item):
			?>
            		<option value="<?php echo $item->KichThuoc ?>" <?php if($selected_kt== $item->KichThuoc) echo 'selected="selected"'  ?>>
						<?php echo $item->KichThuoc ?> inches
                    </option>
            <?php
				endforeach;
			?>
        </select>
        <input type="submit" id="btnsearch" class="btn btn-danger" style="margin-left:114px;" value="Tìm kiếm" />
        </form>
        </div>
      <div class="cl" style="height:10px"> </div>
      <div class="pa-list temp-tree" style="height:110px;">
        <h2>Giỏ hàng</h2>
        <div class="cart_details"> 
        <?php
			if(isset($_SESSION['cart'])){
				$cart = $_SESSION['cart'];
				$tiviModel = new tivi();
				$SoLuong = 0;
				foreach($cart as $tivi_id=>$soluong){
					$tiviModel->getTiviById($tivi_id);
					$tivi = $tiviModel->getTiviById($tivi_id);	
					$SoLuong += $soluong;
				}
				echo $SoLuong.' sản phẩm'; 
			}
			else{
				echo '0 sản phẩm';	
			}
		?>
         <br>
          <span class="border_cart"></span> Total: <span class="price">
          <?php
		  	if(isset($_SESSION['cart'])){
				$cart = $_SESSION['cart'];
				$tiviModel = new tivi();
				$TongTien = 0;
				foreach($cart as $tivi_id=>$soluong){
					$tiviModel->getTiviById($tivi_id);
					$tivi = $tiviModel->getTiviById($tivi_id);	
					$TongTien += $tivi->GiaBan * $soluong;
				}
				echo number_format($TongTien,0,'','.').' đ'; 
			}
			else{
				echo '0 đ';	
			}
		  ?>
          </span> 
        </div>
        <div class="cart_icon">
        	<a href="<?php echo __URL_BASE.'gio-hang.html' ?>">
            	<img src="<?php echo __URL_BASE ?>images/cart.jpg" alt="" width="35" height="35" border="0">
            </a>
        </div>
      </div>
      <div class="cl" style="height:10px"></div>
      
      <div class="cl"> </div>
      <div class="cl"> </div>
      <div class="cl"> </div>
    </div>